<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	template="/WEB-INF/templates/default.xhtml">
	
	<f:metadata>
		<f:viewParam
			name="id" 
			value="#{userTaskBean.id}" />
		<f:event
			type="preRenderView"
			listener="#{userTaskBean.load(currentUser)}" />
	</f:metadata>
	
	<ui:define name="content">
		
		<h:form id="usertaskEditForm" rendered = "#{login.loggedIn}">
  
  			<h:outputLabel for="user" value="User-Task: "/>
			<h:panelGroup>
				<p:inputText id="user" value="#{userTaskBean.userTask.task.name}" />
				<h:message for="user" styleClass="error" />
			</h:panelGroup>
			
			<br /><br />
			
			<h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5">
 
		        <h:outputText value="Status check: " />
		        <p:selectBooleanCheckbox value="#{userTaskBean.userTask.state}" />
		        		 
		    </h:panelGrid>
			
			<br />
  
			<p:growl id="msg" showDetail="true" escape="false" />
 
		    <h3 style="margin-top:0">Resources</h3>
		 
		    <p:pickList id="resList" value="#{userTaskBean.resources}" var="res"
		                itemLabel="#{res}" itemValue="#{res}" />
		         
		    <br />       
		    <h3 style="margin-top:0">Task types</h3>
		 
		    <p:pickList id="taskTypeList" value="#{userTaskBean.taskTypes}" var="taskType"
		                itemLabel="#{taskType}" itemValue="#{taskType}" />
		    <br />
		    
		    <br />       
		    <h3 style="margin-top:0">Collaborators</h3>
		 
		    <p:pickList id="userList" value="#{userTaskBean.users}" var="user"
		                itemLabel="#{user}" itemValue="#{user}" />
		    <br />
		        		
			<p:commandButton 
				value="Save" 
				action="#{userTaskBean.save()}" />
				
			<p:commandButton 
				value="Remove" 
				action="#{userTaskBean.remove()}" rendered="#{userTaskBean.id!=null}"/>
				
			<p:button
				value="Back"
				outcome="/content/usertask/list" />
		
		</h:form>

	</ui:define>
</ui:composition>